package com.musicstore.entity;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;

public class AlbumEntity {
	private int Id;
	private int GenreId;
	private String Artist;
	private String Title;
	private double Price;
	private int Stock;
	//这是json自带的日期格式注解, timezone="GMT+8"设置时区
	@JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
	private Date DateReleased;
	private String Description;
	private GenreEntity genres;
	public AlbumEntity() {
		super();
		// TODO Auto-generated constructor stub
	}
	public AlbumEntity(int id, int genreId, String artist, String title,
			double price, int stock, Date dateReleased, String description,
			GenreEntity genres) {
		super();
		Id = id;
		GenreId = genreId;
		Artist = artist;
		Title = title;
		Price = price;
		Stock = stock;
		DateReleased = dateReleased;
		Description = description;
		this.genres = genres;
	}
	public int getId() {
		return Id;
	}
	public void setId(int id) {
		Id = id;
	}
	public int getGenreId() {
		return GenreId;
	}
	public void setGenreId(int genreId) {
		GenreId = genreId;
	}
	public String getArtist() {
		return Artist;
	}
	public void setArtist(String artist) {
		Artist = artist;
	}
	public String getTitle() {
		return Title;
	}
	public void setTitle(String title) {
		Title = title;
	}
	public double getPrice() {
		return Price;
	}
	public void setPrice(double price) {
		Price = price;
	}
	public int getStock() {
		return Stock;
	}
	public void setStock(int stock) {
		Stock = stock;
	}
	public Date getDateReleased() {
		return DateReleased;
	}
	public void setDateReleased(Date dateReleased) {
		DateReleased = dateReleased;
	}
	public String getDescription() {
		return Description;
	}
	public void setDescription(String description) {
		Description = description;
	}
	public GenreEntity getGenres() {
		return genres;
	}
	public void setGenres(GenreEntity genres) {
		this.genres = genres;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((Artist == null) ? 0 : Artist.hashCode());
		result = prime * result
				+ ((DateReleased == null) ? 0 : DateReleased.hashCode());
		result = prime * result
				+ ((Description == null) ? 0 : Description.hashCode());
		result = prime * result + GenreId;
		result = prime * result + Id;
		long temp;
		temp = Double.doubleToLongBits(Price);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + Stock;
		result = prime * result + ((Title == null) ? 0 : Title.hashCode());
		result = prime * result + ((genres == null) ? 0 : genres.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AlbumEntity other = (AlbumEntity) obj;
		if (Artist == null) {
			if (other.Artist != null)
				return false;
		} else if (!Artist.equals(other.Artist))
			return false;
		if (DateReleased == null) {
			if (other.DateReleased != null)
				return false;
		} else if (!DateReleased.equals(other.DateReleased))
			return false;
		if (Description == null) {
			if (other.Description != null)
				return false;
		} else if (!Description.equals(other.Description))
			return false;
		if (GenreId != other.GenreId)
			return false;
		if (Id != other.Id)
			return false;
		if (Double.doubleToLongBits(Price) != Double
				.doubleToLongBits(other.Price))
			return false;
		if (Stock != other.Stock)
			return false;
		if (Title == null) {
			if (other.Title != null)
				return false;
		} else if (!Title.equals(other.Title))
			return false;
		if (genres == null) {
			if (other.genres != null)
				return false;
		} else if (!genres.equals(other.genres))
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "AlbumEntity [Id=" + Id + ", GenreId=" + GenreId + ", Artist="
				+ Artist + ", Title=" + Title + ", Price=" + Price + ", Stock="
				+ Stock + ", DateReleased=" + DateReleased + ", Description="
				+ Description + ", genres=" + genres + "]";
	}
	
}
